package cn.uexpo.lhz.biz.impl;

import cn.uexpo.lhz.biz.EquipmentService;

import cn.uexpo.lhz.dao.EquipmentDao;
import cn.uexpo.lhz.domain.Equipment;
import cn.uexpo.lhz.plus.PageUtils;
import cn.uexpo.lhz.plus.Query;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author 小坏
 * @Date 2020/8/21 14:57
 * @Version 1.0
 * @program: 父工程 manage-cert 万物起源之地
 */

@Service("equipmentService")
public class EquipmentServiceImpl extends ServiceImpl<EquipmentDao, Equipment> implements EquipmentService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<Equipment> wrapper = new QueryWrapper<>();
        String key = (String) params.get("key");
        if (!StringUtils.isEmpty(key)) {
            wrapper.and((obj)->{
                obj.eq("cameraname",key);
            });
        }

        IPage<Equipment> page = this.page(
                new Query<Equipment>().getPage(params),
                wrapper
        );
        return new PageUtils(page);
    }


}
